<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>文章添加</title>
    <link rel="stylesheet" href="/static/css/layui.css"  media="all">
    <link rel="stylesheet" href="/static/css/diyUpload.css"  >
    <link rel="stylesheet" href="/static/css/webuploader.css"  >
    <script src="/static/js/jquery-3.1.1.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="/static/ueditor/1.4.3/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/static/ueditor/1.4.3/ueditor.all.js"> </script>
    <script type="text/javascript" charset="utf-8" src="/static/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<!--    bootstrap 的轮播图-->
    <link rel="stylesheet" href="//cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="//cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="//cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div id="myCarousel" class="carousel slide" style="width:50%;margin: auto" >
    <!-- 轮播（Carousel）指标 -->
    <ol class="carousel-indicators">
        <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
        <li data-target="#myCarousel" data-slide-to="1"></li>
        <li data-target="#myCarousel" data-slide-to="2"></li>
    </ol>
    <!-- 轮播（Carousel）项目 -->
    <div class="carousel-inner">
        <div class="item active">
            <img src="/uploads/20201225/ccee675fc7c5ef517250cb5fa2cf9a15.jpg" alt="老鼠爱大米" style="width: 100%;" >
        </div>
        <div class="item">
            <img src="/uploads/20201225/ccee675fc7c5ef517250cb5fa2cf9a15.jpg" alt="Second slide" style="width: 100%;">
        </div>
        <div class="item">
            <img src="/uploads/20201225/ccee675fc7c5ef517250cb5fa2cf9a15.jpg" alt="Third slide" style="width: 100%;">
        </div>
    </div>
    <!-- 轮播（Carousel）导航 -->
    <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
    </a>
</div>
<label class="layui-form-label">标题</label>
<div class="layui-input-block">
    <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input" id="title">
</div>
<br>
<!--多图插件上传-->
<label class="layui-form-label">图片</label>
<div id="file"></div>
<input type="hidden" id="img" value="">
<!--ueditor富文本上传-->
<label class="layui-form-label">描述</label>
<div class="layui-input-block">
<textarea name="desc" id="editor" placeholder="" class="" style="width:1024px;height:500px;"></textarea>
</div>
<label class="layui-form-label"></label>
<button type="button" class="layui-btn layui-btn-warm">提交</button>
</body>
<script src="/static/js/jquery-3.1.1.min.js"></script>
<script src="/static/js/diyUpload.js"></script>
<script src="/static/js/webuploader.js"></script>
<script>

  $(function () {
      var imgs=[];
      $("#file").diyUpload({
          'url':'addimg',
          success:function(data){
            imgs.push(data);
            $('#img').val(imgs);
          }
      })
      var ue = UE.getEditor('editor');
      $('button').click(function () {
           var title=$("#title").val();
           var img=$("#img").val();
           var desc=UE.getEditor('editor').getContent();//获取desc的默认值
          console.log(title);
          console.log(desc);
          $.post(
              'create',
              {
                  title:title,
                  img:img,
                  desc:desc
               },
              function (data) {
                 if (data.code==200){
                     location.href='show';
                 }
              }
          )
      })

  })
</script>
</html>